package com.atguigu.tms.mock.mapper;

import com.atguigu.tms.mock.bean.LineBaseShift;
import com.atguigu.tms.mock.mapper.adv.AdvMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 线路基本表 Mapper 接口
 * </p>
 *
 * @author zhangchen
 * @since 2022-06-18
 */
public interface LineBaseShiftMapper extends AdvMapper<LineBaseShift> {


    @Select("SELECT  id,line_id,start_time,est_end_time,driver1_emp_id,driver2_emp_id," +
            "truck_id,pair_shift_id,is_enabled,create_time,update_time,is_deleted  FROM \n" +
            "(\n" +
            "SELECT  *,start_time shift_time\n" +
            "FROM `line_base_shift`\n" +
            "UNION ALL \n" +
            "SELECT   *,CONCAT('TM',start_time) AS shift_time  \n" +
            "FROM `line_base_shift`\n" +
            ")ls  WHERE shift_time > #{curTime}  AND line_id =#{lineId}\n" +
            "ORDER BY shift_time ASC  LIMIT 1 ")
    public  LineBaseShift getNextShiftByLineId(@Param("lineId") Long lineId,@Param("curTime") String curTime);

}
